import 'package:buy_flutter/widgets/common_tabbar_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class MinePage extends StatelessWidget {
  final String headerUrl =
      "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1950846641,3729028697&fm=26&gp=0.jpg";
  final List<Widget> slives = [];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: CommonTabbarContainerWidget(
          titleName: "个人资料",
          isShowBackIcon: false,
        ),
        body: Container(
          color: Color(0xFFE7EBEF),
          child: SingleChildScrollView(
            child: Column(
              children: [_headerView(), _containerView()],
            ),
          ),
        ));
  }

  Widget _headerView() {
    return Container(
      color: Colors.white,
      margin: EdgeInsets.only(top: 10),
      padding: EdgeInsets.symmetric(vertical: 20, horizontal: 10),
      child: Row(
        children: [
          Expanded(
            child: Container(
              width: double.infinity,
              alignment: Alignment.centerLeft,
              height: 60,
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Expanded(
                    child: Text(
                      "小朋友相片",
                      maxLines: 1,
                      style: TextStyle(
                          color: Color(0xFF010101),
                          fontWeight: FontWeight.bold,
                          fontSize: 18),
                    ),
                  ),
                  Container(
                    height: 30,
                    width: 80,
                    alignment: Alignment.center,
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(15),
                      color: Colors.white,
                      border: Border.all(color: Colors.grey, width: 2),
                    ),
                    padding: EdgeInsets.symmetric(horizontal: 15),
                    child: Text("修改"),
                  ),
                ],
              ),
            ),
          ),
          Image.network(
            headerUrl,
            width: 60,
            height: 60,
          ),
        ],
      ),
    );
  }

  Widget _containerView() {
    return Container(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          _userChildInfo(),
          _userInfo(),
          _loginoutView(),
        ],
      ),
    );
  }

  Widget _userChildInfo() {
    return Container(
      color: Colors.white,
      margin: EdgeInsets.only(top: 10),
      padding: EdgeInsets.symmetric(vertical: 20, horizontal: 10),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            "小朋友资料",
            style: TextStyle(
                color: Color(0xFF010101),
                fontSize: 18,
                fontWeight: FontWeight.bold),
          ),
          SizedBox(
            height: 15,
          ),
          _infoName("姓名", "double seven"),
          _infoName("手机", "18792112781"),
        ],
      ),
    );
  }

  Widget _userInfo() {
    return Container(
      color: Colors.white,
      padding: EdgeInsets.symmetric(vertical: 20, horizontal: 10),
      margin: EdgeInsets.only(top: 10),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            "家长资料",
            style: TextStyle(
                color: Color(0xFF010101),
                fontSize: 18,
                fontWeight: FontWeight.bold),
          ),
          SizedBox(
            height: 15,
          ),
          _infoName("手机号码", "double seven"),
          _infoName("电邮", "18792112781"),
        ],
      ),
    );
  }

  Widget _infoName(String label, String content) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Padding(
          padding: const EdgeInsets.symmetric(vertical: 5),
          child: Text(
            label,
            style: TextStyle(
              color: Color.fromRGBO(0, 36, 86, 0.55),
              fontSize: 12,
            ),
          ),
        ),
        Container(
          width: double.infinity,
          height: 44,
          alignment: Alignment.centerLeft,
          padding: EdgeInsets.symmetric(horizontal: 15),
          decoration: BoxDecoration(
              border: Border.all(
                color: Color.fromRGBO(206, 206, 206, 1),
                width: 1,
              ),
              borderRadius: BorderRadius.circular(4)),
          child: Text(
            content,
            style: TextStyle(color: Color(0xFFC7CCD1), fontSize: 14),
          ),
        )
      ],
    );
  }

  Widget _loginoutView() {
    return Container(
      height: 44,
      margin: EdgeInsets.symmetric(vertical: 20, horizontal: 20),
      width: double.infinity,
      child: RaisedButton(
        onPressed: () {},
        color: Color(0xFF3FADA9),
        child: Text("退出登录"),
        textColor: Colors.white,
      ),
    );
  }
}
